<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="p" uri="/pagination-tags"%>
<%@ taglib prefix="security" uri="/security-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><s:property value="titleName"/>查询</title>
</head>
<body> 
<div id="breadcrumbs">
	<div><div><ul>
		<li class="first"></li>
		<li><a href="#">商品数据</a></li>
		<li><a href="#">商品属性管理</a></li>
		<li class="last"><a href="#"><s:property value="titleName"/>查询</a></li>
	</ul></div></div>
</div>
<div class="section">
	<jsp:include page="/common/messages.jsp" />
	<div class="box">
		<div class="title">
			查询条件
			<span class="hide"></span>
		</div>
		<div class="content">
			<s:form action="searchGoodsCategory" namespace="/goods" method="get" id="searchForm">
				<table>
					<tr>
						<th>名称：</th>
						<th><s:textfield name="goodsCategory.name" /></th>
						<th>
							<button type="submit" class="orange" onclick="submitForm('searchGoodsCategory');"><span>查询</span></button>
							<button type="submit" class="blue" onclick="createForm()"><span>新建</span></button>
						</th>
					</tr>
				</table>
			</s:form>
		</div>
	</div>
</div>
<div class="section">
	<div class="box">
		<div class="title">
			查询结果
			<span class="hide"></span>
		</div>
		<div class="content">
			<table id="categoryList"></table> 
			<div id="categoryPager"></div> 		
		</div>
	</div>	
</div>

<script type="text/javascript">
//删除
function delForm(id){
	if (!confirm("确定要删除吗？")){
		return;
	}
	window.location.href = "${dynamicURL}/goods/deleteGoodsCategory.action?goodsCategory.id="+id;
}

function addForm(id){
	window.location.href = "${dynamicURL}/goods/addGoodsCategory.action?goodsCategory.parent.id="+id;
}

//删除
function updateForm(id){
	window.location.href = "${dynamicURL}/goods/updateGoodsCategory.action?goodsCategory.id="+id;
}

function createForm(){
	document.getElementById('searchForm').onsubmit=function(){ return false; };
	window.location.href = "${dynamicURL}/goods/addGoodsCategory.action";
}
function submitForm(action){
	var form = document.getElementById("searchForm");
	form.action="${dynamicURL}/goods/"+action+".action";
	form.submit();
}



var groupListData;

$(document).ready(function (){
	
groupListData ={
		url: 'searchCategory.action', 
		treedatatype: "json",
		mtype: "POST",
		colNames:["id","名称","描述", "级别", "状态",'操作'], 
		colModel:[ 
				{name:'id',index:'id', width:1,hidden:true,key:true}, 
				{name:'name',index:'name', width:180}, 
				{name:'description',index:'description', width:80, align:"center"}, 
				{name:'level',index:'level', width:80, align:"right"}, 
				{name:'statusName',index:'statusName', width:80,align:"right"},
				{name:'btn',index:'btn',align:"center"}
			], 
		height:'auto', 
		autowidth:true,
		shrinkToFit: false,	
		pager : "#categoryPager", 
		treeGrid: true, 
		ExpandColumn : 'name', 
		caption: "查询结果 ",
		jsonReader:{
			root:"pager.records",
			total: "total",
			page: "page",
			records: "records",
			repeatitems: false,
			id:"0" 
			},
		gridComplete:function() {
		        var grid = jQuery("#categoryList");
		        var ids = grid.jqGrid('getDataIDs');	// 获取表格所有 行id
		        for (var i = 0; i < ids.length; i++) {
		            var rowId = ids[i];
		            var rowdata = grid.jqGrid('getRowData', rowId);
		            var btnTemp = "<img title='从组中删除角色' style='cursor:pointer' border='0' src='${staticURL}/default/images/trash.png' onclick='delForm("+rowdata.id+")'>";  
		            grid.jqGrid('setRowData', rowId, { btn: btnTemp}); 
		        } 
		    }	
		};

var STATUS_TYPE = {'N': '禁用', 'N': '启用'}
function satus_type(cellvalue, options, rowObject) {
	return STATUS_TYPE[cellvalue];
}

jQuery("#categoryList").jqGrid(groupListData);

});

</script>
</body>
</html>
